module libeventd.Http ;

import
	libeventd.Types ;

enum{
	HTTP_OK			=200,
	HTTP_NOCONTENT	=204,
	HTTP_MOVEPERM		=301,
	HTTP_MOVETEMP		=302,
	HTTP_NOTMODIFIED	=304,
	HTTP_BADREQUEST	=400,
	HTTP_NOTFOUND		=404,
	HTTP_SERVUNAVAIL	=503,
}


extern(C):

evhttp* evhttp_new(event_base*);
ev_int evhttp_bind_socket(evhttp *http, char *address, ev_uint16_t port);
evhttp_bound_socket* evhttp_bind_socket_with_handle(evhttp *http, char *address, ev_uint16_t port);
ev_int evhttp_accept_socket(evhttp *http, evutil_socket_t fd);
evhttp_bound_socket *evhttp_accept_socket_with_handle(evhttp *http, evutil_socket_t fd);
void evhttp_del_accept_socket(evhttp *http, evhttp_bound_socket *bound_socket);
evutil_socket_t evhttp_bound_socket_get_fd(evhttp_bound_socket *bound_socket);
void evhttp_free(evhttp* http);
void evhttp_set_max_headers_size( evhttp* http, ev_ssize_t max_headers_size);
void evhttp_set_max_body_size( evhttp* http, ev_ssize_t max_body_size);
int evhttp_set_cb( evhttp *http, char *path, void (*cb)( evhttp_request *, void *), void *cb_arg);
int evhttp_del_cb( evhttp *, char *);
void evhttp_set_gencb( evhttp *http,   void (*cb)( evhttp_request *, void *), void *arg);
int evhttp_add_virtual_host( evhttp* http, char *pattern,   evhttp* vhost);
int evhttp_remove_virtual_host( evhttp* http,  evhttp* vhost);
void evhttp_set_timeout( evhttp *http, int timeout_in_secs);
void evhttp_send_error( evhttp_request *req, int error, char *reason);
void evhttp_send_reply( evhttp_request *req, int code, char *reason,  evbuffer *databuf);
void evhttp_send_reply_start( evhttp_request *req, int code, char *reason);
void evhttp_send_reply_chunk( evhttp_request *req,  evbuffer *databuf);
void evhttp_send_reply_end( evhttp_request *req);
evhttp_request *evhttp_request_new(void (*cb)( evhttp_request *, void *), void *arg);
void evhttp_request_set_chunked_cb(evhttp_request *,void (*cb)( evhttp_request *, void *));
void evhttp_request_free( evhttp_request *req);
evhttp_connection *evhttp_connection_base_new( event_base *base,  evdns_base *dnsbase,char *address, ev_ushort port);
void evhttp_request_own( evhttp_request *req);
int evhttp_request_is_owned( evhttp_request *req);
evhttp_connection *evhttp_request_get_connection( evhttp_request *req);
void evhttp_connection_set_max_headers_size( evhttp_connection *evcon, ev_ssize_t new_max_headers_size);
void evhttp_connection_set_max_body_size( evhttp_connection* evcon, ev_ssize_t new_max_body_size);
void evhttp_connection_free( evhttp_connection *evcon);
void evhttp_connection_set_local_address( evhttp_connection *evcon, char *address);
void evhttp_connection_set_local_port( evhttp_connection *evcon, ev_uint16_t port);
void evhttp_connection_set_timeout( evhttp_connection *evcon, int timeout_in_secs);
void evhttp_connection_set_retries( evhttp_connection *evcon,  int retry_max);
void evhttp_connection_set_closecb( evhttp_connection *evcon, void (*)( evhttp_connection *, void *), void *);
void evhttp_connection_get_peer( evhttp_connection *evcon,  char **address, ev_uint16_t *port);
int evhttp_make_request(evhttp_connection *evcon, evhttp_request *req, evhttp_cmd_type type, char *uri);
void evhttp_cancel_request(evhttp_request *req);
char *evhttp_request_get_uri( evhttp_request *req);
 evkeyvalq *evhttp_request_get_input_headers( evhttp_request *req);
 evkeyvalq *evhttp_request_get_output_headers( evhttp_request *req);
 evbuffer *evhttp_request_get_input_buffer( evhttp_request *req);
 evbuffer *evhttp_request_get_output_buffer( evhttp_request *req);
char *evhttp_find_header(evkeyvalq *headers, char *key);
int evhttp_remove_header( evkeyvalq *headers, char *key);
int evhttp_add_header( evkeyvalq *headers, char *key, char *value);
void evhttp_clear_headers( evkeyvalq *headers);
char *evhttp_encode_uri(char *uri);
char *evhttp_decode_uri(char *uri);
void evhttp_parse_query(char *uri,  evkeyvalq *headers);
char *evhttp_htmlescape(char *html);



